using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using net_work.Data.Entity.Cou;

namespace net_work.Config.DataBaseConfig.Cou;

/// <summary>
/// 选课实体配置类
/// </summary>
public class EnrollmentEntityTypeConfiguration : IEntityTypeConfiguration<Enrollment>
{
    public void Configure(EntityTypeBuilder<Enrollment> builder)
    {
        builder.ToTable("cou_enr");

        builder.HasKey(e => e.Id);

        // 配置字段名映射
        builder.Property(e => e.Id).HasColumnName("enr_id");

        builder.Property(e => e.EnrollmentScore)
            .HasColumnName("enr_score")
            .HasColumnType("decimal(4,1)");

        builder.Property(e => e.TeachId).HasColumnName("teach_id").IsRequired();
        builder.Property(e => e.StudentId).HasColumnName("stu_id").IsRequired();

        builder.Property(e => e.CreatedBy).HasColumnName("create_by").IsRequired().HasMaxLength(64);
        builder.Property(e => e.CreatedTime).HasColumnName("create_time").IsRequired();
        builder.Property(e => e.UpdatedBy).HasColumnName("update_by").IsRequired().HasMaxLength(64);
        builder.Property(e => e.UpdatedTime).HasColumnName("update_time").IsRequired();
        builder.Property(e => e.Remark).HasColumnName("remark").HasMaxLength(256);
        builder.Property(e => e.DelFlag).HasColumnName("del_flag").HasDefaultValue('0');
    }
}